<template>
  <div class="profile-page">
    <!-- 标签页切换和操作图标 -->
    <div class="tab-bar-container">
      <div class="tab-bar">
        <button
            class="tab-button"
            :class="{ active: activeTab === 'dynamic' }"
            @click="activeTab = 'dynamic'"
        >
          动态
        </button>
        <button
            class="tab-button"
            :class="{ active: activeTab === 'data' }"
            @click="activeTab = 'data'"
        >
          数据
        </button>
      </div>
      <div class="icons-container">
        <!-- 搜索图标按钮 -->
        <div class="icon-button" @click="toggleSearch">
          <svg
              xmlns="http://www.w3.org/2000/svg"
              width="20"
              height="20"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
          >
            <circle cx="11" cy="11" r="8"></circle>
            <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
          </svg>
        </div>
        <!-- 个人消息图标按钮 -->
        <div class="icon-button" @click="goMessages">
          <svg
              xmlns="http://www.w3.org/2000/svg"
              width="20"
              height="20"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
          >
            <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
          </svg>
        </div>
      </div>
    </div>

    <!-- 搜索栏 -->
    <div v-if="showSearch" class="search-bar">
      <input
          type="text"
          placeholder="搜索用户相关内容..."
          v-model="searchKeyword"
          class="search-input"
          @input="handleSearch"
      />
      <button class="search-clear-btn" @click="clearSearch">
        <svg
            xmlns="http://www.w3.org/2000/svg"
            width="16"
            height="16"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
        >
          <line x1="18" y1="6" x2="6" y2="18"></line>
          <line x1="6" y1="6" x2="18" y2="18"></line>
        </svg>
      </button>
    </div>

    <!-- 用户信息栏 -->
    <div class="user-header">
      <div class="user-info-container">
        <div class="avatar-container">
          <img :src="user.avatar" alt="头像" class="avatar" />
          <div class="online-status"></div>
        </div>
        <div class="user-info">
          <div class="nickname">{{ user.nickname }}</div>
          <div class="level-container">
            <span class="level-badge">Lv.{{ user.level }}</span>
            <!--            经验条-->
            <!--            <div class="level-progress">-->
            <!--              <div class="level-progress-bar" :style="{ width: '60%' }"></div>-->
            <!--            </div>-->
          </div>
          <div class="signature" @click="editSignature">{{ user.signature || '点击编辑个性签名' }}</div>
        </div>
      </div>
      <div class="stats">
        <div class="stat-item" @click="goFollows">
          <div class="number">{{ user.following }}</div>
          <div class="label">关注</div>
        </div>
        <div class="stat-item" @click="goFans">
          <div class="number">{{ user.followers }}</div>
          <div class="label">粉丝</div>
        </div>
        <div class="stat-item" @click="goCollections">
          <div class="number">{{ user.collections }}</div>
          <div class="label">收藏</div>
        </div>
        <div class="stat-item">
          <div class="number">{{ user.history }}</div>
          <div class="label">历史浏览</div>
        </div>
      </div>
    </div>

    <!-- 内容区域 -->
    <div class="content-area">
      <!-- 动态页面内容 -->
      <div v-if="activeTab === 'dynamic'" class="dynamic-content">
        <div class="tabs">
          <button
              class="tab"
              :class="{ active: dynamicActiveTab === 'posts' }"
              @click="dynamicActiveTab = 'posts'"
          >
            动态
          </button>
          <button
              class="tab"
              :class="{ active: dynamicActiveTab === 'submissions' }"
              @click="dynamicActiveTab = 'submissions'"
          >
            投稿
          </button>
        </div>
        <div class="main-content">
          <ur>
            <li v-if="userPosts.length > 0" v-for="post in userPosts" :key="post.id" class="post-item">
              <div class="post-card">
                <div class="post-header">
                  <img :src="user.avatar" :alt="user.nickname" class="post-author-avatar" />
                  <div class="post-author-info">
                    <div class="post-author-name">{{user.nickname }}</div>
                    <div class="post-time">{{ post.publishTime }}</div>
                  </div>
                  <div class="post-menu">
                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                      <circle cx="12" cy="12" r="1"></circle>
                      <circle cx="12" cy="5" r="1"></circle>
                      <circle cx="12" cy="19" r="1"></circle>
                    </svg>
                  </div>
                </div>
                <div class="post-content">
                  {{ post.content }}
                </div>
                <div class="post-stats">
                  <div class="stat-item">
                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                      <path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"></path>
                    </svg>
                    <span>{{ post.likeCount }}</span>
                  </div>
                  <div class="stat-item">
                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                      <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
                    </svg>
                    <span>{{ post.commentCount }}</span>
                  </div>
                  <div class="stat-item">
                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                      <path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"></path>
                    </svg>
                    <span>{{ post.collectCount }}</span>
                  </div>
                </div>
              </div>
            </li>
            <li v-else class="no-comments">
              <div class="inspiration">
                <div class="icon-container">
                  <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                    <path d="M12 20h9"></path>
                    <path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"></path>
                  </svg>
                </div>
                <div class="title">创作灵感</div>
                <div class="subtitle">猛兽派对二周年</div>
                <button class="publish-btn">去发布 ></button>
              </div>
            </li>
          </ur>
        </div>
      </div>

      <!-- 数据页面内容 -->
      <div v-else class="data-content">
        <div class="data-tabs">
          <button
              class="data-tab"
              :class="{ active: dataActiveTab === 'games' }"
              @click="dataActiveTab = 'games'"
          >
            关注游戏
          </button>
          <button
              class="data-tab"
              :class="{ active: dataActiveTab === 'ratings' }"
              @click="dataActiveTab = 'ratings'"
          >
            我的评分
          </button>
        </div>
        <div class="data-list">
          <div v-if="dataActiveTab === 'games'" class="">
            <ul>
              <li v-if="userGames.value && userGames.value.length > 0" v-for="game in userGames.value" :key="game.gameId" class="game-item">
                <div class="game-cover">
                  <img :src="game.coverImage" alt="游戏封面" />
                </div>
                <div class="game-info">
                  <div class="game-name">{{ game.gameName }}</div>
                  <div class="game-intro">{{ game.intro }}</div>
                  <div class="game-meta">
                    <div class="game-rating">
                      <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                        <polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon>
                      </svg>
                      <span>{{ game.score }}</span>
                    </div>
                  </div>
                </div>
              </li>
              <li v-else class="no-games">
                <div class="empty-state">
                  <div class="empty-icon">
                    <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                      <path d="M12 20h9"></path>
                      <path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"></path>
                    </svg>
                  </div>
                  <p class="empty-text">暂无关注游戏</p>
                  <p class="empty-subtext">快去关注你喜欢的游戏吧～</p>
                </div>
              </li>
            </ul>
          </div>
          <div v-else class="">
            <ul>
              <li v-if="userGames.value && userGames.value.length > 0" v-for="rating in userGames.value" :key="rating.gameId" class="rating-item">
                <!-- 游戏信息和评分 -->
                <div class="rating-header">
                  <div class="rating-cover-container">
                    <img :src="rating.coverImage" alt="封面" class="cover" />
                  </div>
                  <div class="user-info">
                    <div class="nickname">{{ rating.gameName }}</div>
                    <div class="rating-score-container">
                      <div class="rating-stars">
                        <svg v-for="i in calculateStars(rating.score)" :key="i" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="#FFD700" stroke="#FFD700" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                          <polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon>
                        </svg>
                        <svg v-for="i in (5 - calculateStars(rating.score))" :key="i+10" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#FFD700" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                          <polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon>
                        </svg>
                      </div>
                      <div class="rating-score">{{ rating.score }}分</div>
                    </div>
                  </div>
                </div>

                <!-- 评分内容 -->
                <div class="rating-content">
                  {{ rating.content }}
                </div>

                <!-- 讨论度和时间 -->
                <div class="rating-footer">
                  <div class="discussion-count">
                    <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                      <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
                    </svg>
                    24
                  </div>
                  <div class="time">
                    2小时前
                  </div>
                </div>
              </li>
              <li v-else>
                <div class="no-ratings">
                  <div class="rating-icon-container">
                    <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                      <polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon>
                    </svg>
                  </div>
                  <div class="rating-title">暂无评分记录</div>
                  <div class="rating-desc">请先为游戏打分</div>
                </div>
              </li>
            </ul>
          </div>

        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import {ref, reactive, onMounted} from 'vue';
import { useRoute, useRouter } from "vue-router";
import axios from "@/utils/axios.ts";

const route = useRoute();
const router = useRouter();

// 控制搜索栏显示
const showSearch = ref(false);
// 搜索关键词
const searchKeyword = ref('');

// 用户数据
const user = reactive({
  userId: 0, // 修改为动态获取
  avatar: '/src/assets/vue.svg', // 默认头像
  nickname: '',
  signature: '',
  level: 1, // 默认等级
  //关注
  following: 0,
  //粉丝
  followers: 0,
  //收藏
  collections: 0,
  //历史
  history: 0,
});
//游戏数据
const userGames = reactive([])
//用户动态数据
const userPosts = ref([])

// 获取当前用户信息
const getCurrentUser = async () => {
  try {
    const token = localStorage.getItem('token');
    const response = await axios.get('/api/users/current', {
      headers: { 'Authorization': `Bearer ${token}` }
    });

    if (response.code === 200) {
      return response.data;
    }
    return null;
  } catch (error) {
    console.error("获取当前用户信息失败:", error);
    return null;
  }
};

//用户初始化
const userInit = async () => {
  try {
    // 首先获取当前登录用户信息
    const currentUser = await getCurrentUser();
    if (currentUser) {
      user.userId = currentUser.userId;
      user.nickname = currentUser.nickname;
      user.avatar = currentUser.avatar || '/src/assets/vue.svg';
      user.signature = currentUser.intro || '';
      user.level = currentUser.level || 1;
    } else {
      // 如果获取失败，使用默认值
      user.userId = 0;
      user.nickname = '未知用户';
      user.avatar = '/src/assets/vue.svg';
      user.signature = '';
      user.level = 1;
      return;
    }

    // 获取用户关注数
    const userFollowCountUrl = '/api/follows/getFollowsById?id='+ user.userId;
    axios.get(userFollowCountUrl).then(res=>{
      user.following = res.data.length;
    }).catch(err => {
      console.error("获取关注数失败:", err);
    });

    // 获取用户粉丝数
    const userFansCountUrl = '/api/follows/getFansById?id='+ user.userId;
    axios.get(userFansCountUrl).then(res=>{
      user.followers = res.data.length;
    }).catch(err => {
      console.error("获取粉丝数失败:", err);
    });

    // 获取用户收藏数
    const userCollectionCountUrl = '/api/postCollections/getUserPostsAndAuthor?userId='+ user.userId;
    axios.get(userCollectionCountUrl).then(res=>{
      user.collections = res.data.length;
    }).catch(err => {
      console.error("获取收藏数失败:", err);
    });
  } catch (error) {
    console.error("用户初始化失败:", error);
  }
};

//用户动态初始化
const userPostsInit = () =>{
  // 确保用户ID已获取
  if (!user.userId) return;

  const userPostUrl = '/api/posts/getUserPosts?id='+ user.userId;
  axios.get(userPostUrl).then(res=>{
    userPosts.value = res.data;
  }).catch(err=>{
    console.log(err);
  });
};

//用户游戏初始化
const userGamesInit = () =>{
  // 确保用户ID已获取
  if (!user.userId) return;

  const userGameUrl = '/api/userGames/getUserGames?userId='+ user.userId;
  axios.get(userGameUrl).then(res=>{
    console.log(res.data);
    userGames.value = res.data;
    console.log(userGames.value);
  }).catch(err=>{
    console.log(err);
  });
};

// 计算评分对应的星数
const calculateStars = (score) => {
  // 10分制转5星制，每2分等于1颗星
  return Math.round(score / 2);
};

onMounted(async ()=>{
  await userInit();
  userPostsInit();
  userGamesInit();
});

// 页面切换状态
const activeTab = ref<'dynamic' | 'data'>('dynamic');
const dynamicActiveTab = ref<'posts' | 'submissions'>('posts');
const dataActiveTab = ref<'games' | 'ratings'>('games');

// 切换搜索栏显示状态
const toggleSearch = () => {
  showSearch.value = !showSearch.value;
};

// 清除搜索
const clearSearch = () => {
  searchKeyword.value = '';
};

// 处理搜索输入
const handleSearch = () => {
  // 实际项目中这里会调用搜索API
  console.log('搜索关键词:', searchKeyword.value);
};

// 编辑签名事件
const editSignature = () => {
  alert('编辑个性签名功能待实现');
};

// 跳转关注页面
const goFollows = () => {
  router.push({
    name: 'follows',
    params: {
      id: user.userId,
    },
    query: {
      tab: 'follow'
    }
  });
};

// 跳转粉丝页面
const goFans = () => {
  router.push({
    name: 'follows',
    params: {
      id: user.userId,
    },
    query: {
      tab: 'fans'
    }
  });
};

// 跳转收藏页面
const goCollections = () => {
  router.push({
    name: 'collections',
    params: {
      id: user.userId,
    },
  });
};

// 跳转消息页面
const goMessages = () => {
  router.push({
    name: 'messages',
    params: {
      id: user.userId,
    },
  });
};

</script>

<style scoped>
.profile-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4edf9 100%);
  overflow: hidden;
}

.user-header {
  padding: 20px;
  background: linear-gradient(120deg, #ffffff, #f8f9ff);
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.user-info-container {
  display: flex;
  align-items: center;
  gap: 16px;
}

.avatar-container {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.online-status {
  position: absolute;
  bottom: 5px;
  right: 5px;
  width: 14px;
  height: 14px;
  background-color: #4ade80;
  border: 2px solid #fff;
  border-radius: 50%;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.nickname {
  font-size: 20px;
  font-weight: bold;
  color: #1e293b;
}

.level-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.level-badge {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
}

.level-progress {
  flex: 1;
  height: 6px;
  background-color: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.level-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 3px;
}

.signature {
  font-size: 14px;
  color: #64748b;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  background-color: #f1f5f9;
  transition: background-color 0.3s;
  width: fit-content;
}

.signature:hover {
  background-color: #e2e8f0;
}

.stats {
  display: flex;
  justify-content: space-around;
  margin-top: 16px;
  background: white;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.stat-item {
  text-align: center;
  cursor: pointer;
  flex: 1;
  padding: 6px;
  border-radius: 8px;
  transition: background-color 0.3s;
}

.stat-item:hover {
  background-color: #f8fafc;
}

.number {
  font-size: 18px;
  font-weight: bold;
  color: #1e293b;
}

.label {
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
}

.tab-bar-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(120deg, #ffffff, #f8f9ff);
  border-bottom: 1px solid #e5e5e5;
  padding: 0 16px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}

.tab-bar {
  display: flex;
  flex: 1;
}

.tab-button {
  padding: 14px 0;
  font-size: 16px;
  border: none;
  background: none;
  cursor: pointer;
  color: #64748b;
  margin-right: 24px;
  font-weight: 500;
  position: relative;
  transition: color 0.3s;
}

.tab-button.active {
  color: #667eea;
}

.tab-button.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 3px;
}

.icons-container {
  display: flex;
  align-items: center;
  gap: 16px;
}

.icon-button {
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background-color 0.3s;
}

.icon-button:hover {
  background-color: #f1f5f9;
}

.search-bar {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  background: linear-gradient(120deg, #ffffff, #f8f9ff);
  border-bottom: 1px solid #e5e5e5;
}

.search-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  outline: none;
  font-size: 14px;
  background-color: #f8fafc;
  transition: all 0.3s;
}

.search-input:focus {
  border-color: #667eea;
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-clear-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  margin-left: 8px;
  border-radius: 50%;
  transition: background-color 0.3s;
}

.search-clear-btn:hover {
  background-color: #f1f5f9;
}

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4edf9 100%);
}

.dynamic-content,
.data-content {
  background: white;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.tabs {
  display: flex;
  margin-bottom: 20px;
  background: #f1f5f9;
  border-radius: 12px;
  padding: 4px;
}

.tab {
  flex: 1;
  padding: 10px;
  font-size: 16px;
  border: none;
  background: none;
  cursor: pointer;
  color: #64748b;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.3s;
}

.tab.active {
  background: white;
  color: #667eea;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.main-content {
  text-align: center;
  padding: 0;
}

.inspiration {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 16px;
}

.icon-container {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.title {
  font-size: 18px;
  font-weight: bold;
  color: #1e293b;
}

.subtitle {
  font-size: 14px;
  color: #64748b;
}

.publish-btn {
  padding: 12px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  font-weight: 500;
  transition: transform 0.2s, box-shadow 0.2s;
  margin-top: 8px;
}

.publish-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.data-tabs {
  display: flex;
  margin-bottom: 20px;
  background: #f1f5f9;
  border-radius: 12px;
  padding: 4px;
}

.data-tab {
  flex: 1;
  padding: 10px;
  font-size: 16px;
  border: none;
  background: none;
  cursor: pointer;
  color: #64748b;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.3s;
}

.data-tab.active {
  background: white;
  color: #667eea;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.data-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 游戏项样式 */
.game-item {
  display: flex;
  gap: 16px;
  background: white;
  padding: 12px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s, box-shadow 0.3s;
  border: 1px solid #f1f5f9;
}

.game-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.game-cover {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.game-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.game-name {
  font-size: 16px;
  font-weight: bold;
  color: #1e293b;
  margin-bottom: 8px;
}

.game-intro {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.game-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-rating {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #64748b;
}

/* 评分项样式 */
.rating-item {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 0px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s, box-shadow 0.3s;
  border: 1px solid #f1f5f9;
}

.rating-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.rating-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.rating-cover-container {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rating-score-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rating-stars {
  display: flex;
  gap: 2px;
}

.rating-score {
  font-size: 14px;
  color: #64748b;
  font-weight: 500;
}

.rating-content {
  font-size: 14px;
  color: #334155;
  line-height: 1.5;
  margin-bottom: 12px;
  white-space: pre-wrap;
}

.rating-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #94a3b8;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

.discussion-count {
  display: flex;
  align-items: center;
  gap: 4px;
}

.time {
  font-size: 12px;
}

/* 帖子样式 */
.post-item {
  list-style: none;
  margin-bottom: 16px;
}

.post-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  padding: 16px;
  text-align: left;
  transition: transform 0.3s, box-shadow 0.3s;
  border: 1px solid #f1f5f9;
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.post-header {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.post-author-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 12px;
  object-fit: cover;
  border: 2px solid #f1f5f9;
}

.post-author-info {
  flex: 1;
}

.post-author-name {
  font-weight: bold;
  color: #1e293b;
  font-size: 16px;
}

.post-time {
  font-size: 12px;
  color: #94a3b8;
}

.post-menu {
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: background-color 0.3s;
}

.post-menu:hover {
  background-color: #f1f5f9;
  color: #64748b;
}

.post-content {
  font-size: 15px;
  color: #334155;
  line-height: 1.6;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

/* 帖子统计数据样式 */
.post-stats {
  display: flex;
  justify-content: flex-start;
  gap: 24px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
  margin-top: 8px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #64748b;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.stat-item:hover {
  color: #1e293b;
}

.stat-item svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s;
}

.stat-item:hover svg {
  transform: scale(1.1);
}

/* 空状态样式 */
.no-comments {
  list-style: none;
  padding: 40px 0;
}

.no-games {
  list-style: none;
  padding: 40px 20px;
  text-align: center;
}

.no-ratings {
  text-align: center;
  padding: 32px 16px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.empty-icon {
  margin-bottom: 16px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  padding: 12px;
}

.empty-text {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 8px;
}

.empty-subtext {
  font-size: 14px;
  color: #64748b;
}

.rating-icon-container {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd700, #ffa500);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  margin: 0 auto 16px;
}

.rating-title {
  font-size: 18px;
  font-weight: bold;
  color: #1e293b;
  margin-bottom: 8px;
}

.rating-desc {
  font-size: 14px;
  color: #64748b;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .user-header {
    padding: 16px;
  }

  .avatar-container {
    width: 60px;
    height: 60px;
  }

  .nickname {
    font-size: 18px;
  }

  .content-area {
    padding: 12px;
  }

  .post-stats {
    gap: 16px;
  }

  .stat-item {
    font-size: 13px;
  }
  .stat-item svg {
    width: 14px;
    height: 14px;
  }
}
</style>
